package org.example.jdk8.stream;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Stream;

public class test1 {
    public static void main(String[] args) {
        List<Integer> list = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9);
        System.out.println(list.stream().map(x -> x * 2).reduce(Integer::sum).orElseGet(() -> 0));

       Stream<List<Integer>> stream = Stream.of(Arrays.asList(1),Arrays.asList(2,3),Arrays.asList(4,5,6));
       stream.flatMap(theList->theList.stream()).map(item->item*item).forEach(System.out::println);
    }
}
